﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DicasViagens.Data;
using Win8Catalog.Win8Catalogo.Model;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace DicasViagens.VariableTemplate
{
    public class VariableTiles:DataTemplateSelector
    {
        public DataTemplate WideTemplate { get; set; }
        public DataTemplate SquareTemplate { get; set; }
        public DataTemplate NormalTemplate { get; set; }
        public DataTemplate VerticalTemplate { get; set; }
        public DataTemplate DetailTemplate { get; set; }
        public DataTemplate SmallNormalTemplate { get; set; }
        public DataTemplate SmallWideTemplate { get; set; }
        public DataTemplate SmallVerticalTemplate { get; set; }

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;
            if (element != null && item != null)
            {
                if (item.GetType() == typeof(Item))
                {
                    if ((item as Item).Template.Equals("Square"))
                        return SquareTemplate;
                    if ((item as Item).Template.Equals("Normal"))
                        return NormalTemplate;
                    if ((item as Item).Template.Equals("Vertical"))
                        return VerticalTemplate;
                    if ((item as Item).Template.Equals("Detail"))
                        return DetailTemplate;
                    if ((item as Item).Template.Equals("SmallNormal"))
                        return SmallNormalTemplate;
                    if ((item as Item).Template.Equals("SmallWide"))
                        return SmallWideTemplate;
                    if ((item as Item).Template.Equals("SmallVertical"))
                        return SmallVerticalTemplate;
                }

            }      
              
           

            return base.SelectTemplateCore(item, container);
        }
    }
}
